Post-merge-review: Fix template-no-at-ember-render-modifiers: detect GJS/GTS imports#2664
Open
johanrd wants to merge 2 commits intoember-cli:masterfrom
Open
Conversation
In GJS/GTS, @ember/render-modifiers is consumed via per-modifier default imports (e.g. 'import didInsert from "@ember/render-modifiers/modifiers/did-insert"'). The local name is user-chosen, so the rule can't match on a hardcoded kebab-case list. Track ImportDeclaration nodes in strict-mode files and flag modifier usages based on the local import name. HBS behavior is unchanged: the canonical kebab-case names (did-insert, did-update, will-destroy) are still flagged via resolver-style matching, matching upstream ember-template-lint.
| @@ -1,3 +1,13 @@ | |||
| // Map of `@ember/render-modifiers` sub-path → canonical kebab-case modifier name. | |||
| // Default-imported names are user-chosen, so we track local names to canonical. | |||
| const RENDER_MODIFIER_IMPORT_PATHS = { | |||
Contributor
There was a problem hiding this comment.
and also: @ember/render-modifiers -- all 3 can be imported from there
bb52db7 to
82efbe4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's broken on
masterThe rule matches a hardcoded kebab-case list (
did-insert,did-update,will-destroy). That works for classic.hbswhere the resolver exposes modifiers by their canonical name, but it misses the GJS/GTS usage entirely:Here the local name is user-chosen (could be
didInsert,onInsert,myInsert, anything). The rule has no way to match the user's identifier against the render-modifier import.Fix
In
.gjs/.gtsfiles, trackImportDeclarationnodes whose source is one of@ember/render-modifiers/modifiers/did-insert/did-update/will-destroy, recording the default-import local name → canonical kebab name. Flag modifier usages whose identifier matches a tracked local name. In.hbs, keep the kebab-case matching (matches upstream ember-template-lint exactly — upstream is HBS-only).Pattern is the same as
template-no-builtin-form-components, which already tracks@ember/componentimports in strict mode.Test plan
didInsert/didUpdate/willDestroyimports (and a renamedmyInsert) fail on master — master silently ignores them alldidInsertfrom a non-render-modifiers path is not flaggedCo-written by Claude.